// ViewSettings.h

#ifndef __VIEW_SETTINGS_H
#define __VIEW_SETTINGS_H

#include "Common/MyFixes.h"

#include <vector>

struct CColumnInfo
{
	PROPID PropID;
	bool IsVisible;
	UINT32 Width;
};

inline bool operator==(const CColumnInfo &a1, const CColumnInfo &a2)
{
	return (a1.PropID == a2.PropID) &&
		   (a1.IsVisible == a2.IsVisible) && (a1.Width == a2.Width);
}

inline bool operator!=(const CColumnInfo &a1, const CColumnInfo &a2)
{
	return !(a1 == a2);
}

struct CListViewInfo
{
	typedef std::vector<CColumnInfo> ColumnsType;
	ColumnsType Columns;
	PROPID SortID;
	bool Ascending;

	void Clear()
	{
		SortID = 0;
		Ascending = true;
		Columns.clear();
	}

	int FindColumnWithID(PROPID propID) const
	{
		for (size_t i = 0; i < Columns.size(); i++)
			if (Columns[i].PropID == propID)
			{
				return i;
			}
		return -1;
	}

	bool IsEqual(const CListViewInfo &info) const
	{
		if (Columns.size() != info.Columns.size() ||
				SortID != info.SortID ||
				Ascending != info.Ascending)
		{
			return false;
		}
		for (size_t i = 0; i < Columns.size(); i++)
			if (Columns[i] != info.Columns[i])
			{
				return false;
			}
		return true;
	}
};

void SaveListViewInfo(const CString &id, const CListViewInfo &viewInfo);
void ReadListViewInfo(const CString &id, CListViewInfo &viewInfo);

void SaveWindowSize(const RECT &rect, bool maximized);
bool ReadWindowSize(RECT &rect, bool &maximized);

void SavePanelsInfo(UINT32 numPanels, UINT32 currentPanel, UINT32 splitterPos);
bool ReadPanelsInfo(UINT32 &numPanels, UINT32 &currentPanel);

void SaveToolbarsMask(UINT32 toolbarMask);
UINT32 ReadToolbarsMask();

void SavePanelPath(const CString &path);
bool ReadPanelPath(CString &path);

struct CListMode
{
	UINT32 Panel;
	void Init()
	{
		Panel = 3;
	}
	CListMode()
	{
		Init();
	}
};

void SaveListMode(const CListMode &listMode);
void ReadListMode(CListMode &listMode);

void SaveFolderHistory(const CStringVector &folders);
void ReadFolderHistory(CStringVector &folders);

void SaveFastFolders(const CStringVector &folders);
void ReadFastFolders(CStringVector &folders);

void SaveCopyHistory(const CStringVector &folders);
void ReadCopyHistory(CStringVector &folders);

void AddUniqueStringToHeadOfList(CStringVector &list, const CString &s);

#endif
